package com.coco.controller;

import com.coco.model.RecordInfo;
import com.coco.model.RecordModel;
import com.coco.service.RecordService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author GHOSTLaycoo
 * @date 2020/4/28 - 9:38
 */
@RestController
@RequestMapping("record")
public class RecordController {

    @Autowired
    private RecordService recordService;

    @ApiOperation(value = "新增浏览记录")
    @PostMapping("/save")
    public ResponseEntity<Integer> save(@RequestBody RecordModel recordModel){
        return ResponseEntity.ok(recordService.save(recordModel));
    }

    @ApiOperation(value = "批量删除浏览记录")
    @DeleteMapping("/delete/{userId}")
    public ResponseEntity<Integer> delete(@PathVariable("userId") String userId){
        return ResponseEntity.ok(recordService.delete(userId));
    }

    @ApiOperation(value = "查询浏览记录")
    @GetMapping("/searchRecord/{userId}")
    public ResponseEntity<List<RecordInfo>> searchRecord(@PathVariable String userId){
        return ResponseEntity.ok(recordService.searchRecord(userId));
    }



}
